package cn.jjxx.modules.screen.vo;

import java.io.Serializable;
import java.util.List;

/**
 * 针对MyBatis-Plus的分页工具
 */
 
public class MPage<T> implements Serializable {

    private static final long serialVersionUID = -6518424048053226824L;

    private final long page;

    private final long size;

    private final long total;

    private final long pages;

    private final List<T> list;

    public MPage(long page, long size, long total, long pages, List<T> records) {
        this.page = page;
        this.size = size;
        this.total = total;
        this.pages = pages;
        this.list = records;
    }

    public static <T> MPage<T> pageInfo(IPage<?> pageInfo, Class<T> clazz) {
        List<?> content = pageInfo.getRecords();
        List<T> lists = BeanUtils.deepSourceListToTargetList(content, clazz);
        return pageInfo(pageInfo, lists);
    }

    public static <T> MPage<T> pageInfo(IPage<?> pageInfo, List<T> lists) {
        return new MPage<>(pageInfo.getCurrent(), pageInfo.getSize(), pageInfo.getTotal(), pageInfo.getPages(), lists);
    }

	/**
	 * @return the serialversionuid
	 */
	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	/**
	 * @return the page
	 */
	public long getPage() {
		return page;
	}

	/**
	 * @return the size
	 */
	public long getSize() {
		return size;
	}

	/**
	 * @return the total
	 */
	public long getTotal() {
		return total;
	}

	/**
	 * @return the pages
	 */
	public long getPages() {
		return pages;
	}

	/**
	 * @return the list
	 */
	public List<T> getList() {
		return list;
	}
    
    
}
